package VISTA;
import java.awt.BorderLayout;
import java.awt.event.ActionListener;

import javax.swing.BorderFactory;
import javax.swing.ComboBoxModel;
import javax.swing.DefaultComboBoxModel;
import javax.swing.JButton;
import javax.swing.JComboBox;
import javax.swing.JLabel;
import javax.swing.JOptionPane;
import javax.swing.JPanel;
import javax.swing.JScrollPane;
import javax.swing.JTable;
import javax.swing.JTextField;
import javax.swing.JViewport;

import javax.swing.WindowConstants;
import javax.swing.table.DefaultTableModel;
import javax.swing.table.TableModel;
import javax.swing.SwingUtilities;

import bean.JTextFieldValidator;
import CONTROLADOR.ControladorCategorias;

/**
* This code was edited or generated using CloudGarden's Jigloo
* SWT/Swing GUI Builder, which is free for non-commercial
* use. If Jigloo is being used commercially (ie, by a corporation,
* company or business for any purpose whatever) then you
* should purchase a license for each developer using Jigloo.
* Please visit www.cloudgarden.com for details.
* Use of Jigloo implies acceptance of these licensing terms.
* A COMMERCIAL LICENSE HAS NOT BEEN PURCHASED FOR
* THIS MACHINE, SO JIGLOO OR THIS CODE CANNOT BE USED
* LEGALLY FOR ANY CORPORATE OR COMMERCIAL PURPOSE.
*/
public class frmCategorias extends javax.swing.JFrame {
	private JPanel pnlCategorias;
	private JTextFieldValidator txtCodigo;
	private JButton btnModificarCategorias;
	private JButton btnCancelarCategorias;
	private JTable tblCategorias;
	private JScrollPane scpCategorias;
	private JButton btnOkCategorias;
	private JButton btnBuscar;
	private JTextField txtDescripcion;
	private JLabel lblDescripcion;
	private JLabel lblCodigo;
	private JPanel pnlDatosCategorias;

	private ControladorCategorias ctrlCategorias;
	
	
	
	public frmCategorias() {
		super("Registro de Categorias");
		initGUI();
	}
	
	private void initGUI() {
		try {
			setDefaultCloseOperation(WindowConstants.DISPOSE_ON_CLOSE);
			{
				pnlCategorias = new JPanel();
				getContentPane().add(pnlCategorias, BorderLayout.CENTER);
				pnlCategorias.setLayout(null);
				pnlCategorias.setBackground(new java.awt.Color(255,255,255));
				pnlCategorias.setLayout(null);
				pnlCategorias.setPreferredSize(new java.awt.Dimension(436, 436));
				{
					
					pnlDatosCategorias = new JPanel();
					pnlDatosCategorias.setBorder(BorderFactory.createTitledBorder("Datos"));
					pnlCategorias.add(pnlDatosCategorias);
					pnlDatosCategorias.setLayout(null);
					pnlDatosCategorias.setBounds(62, 23, 437, 211);
					pnlDatosCategorias.setBackground(new java.awt.Color(228,196,116));
					pnlDatosCategorias.setEnabled(false);
					{
						lblCodigo = new JLabel();
						pnlDatosCategorias.add(lblCodigo);
						lblCodigo.setText("Codigo:");
						lblCodigo.setBounds(17, 44, 70, 28);
					}
					{
						txtCodigo = new JTextFieldValidator(JTextFieldValidator.SOLO_NUMEROS);
						pnlDatosCategorias.add(txtCodigo);
						txtCodigo.setBounds(118, 44, 138, 25);
					}
					{
						lblDescripcion = new JLabel();
						pnlDatosCategorias.add(lblDescripcion);
						lblDescripcion.setText("Descripcion:");
						lblDescripcion.setBounds(17, 84, 89, 21);
					}
					{
						txtDescripcion = new JTextField();
						pnlDatosCategorias.add(txtDescripcion);
						txtDescripcion.setBounds(118, 81, 169, 24);
					}
					{
						btnOkCategorias = new JButton();
						pnlDatosCategorias.add(btnOkCategorias);
						btnOkCategorias.setText("OK");
						btnOkCategorias.setBounds(22, 141, 104, 32);
					}
					{
						btnCancelarCategorias = new JButton();
						pnlDatosCategorias.add(btnCancelarCategorias);
						btnCancelarCategorias.setText("Cancelar");
						btnCancelarCategorias.setBounds(312, 143, 103, 32);
						btnCancelarCategorias.setActionCommand("Cancelar");
					}
					{
						btnBuscar = new JButton();
						pnlDatosCategorias.add(btnBuscar);
						btnBuscar.setText("Buscar");
						btnBuscar.setActionCommand("Buscar");
						btnBuscar.setBounds(287, 40, 99, 32);
					}
					{
						btnModificarCategorias = new JButton();
						pnlDatosCategorias.add(btnModificarCategorias);
						btnModificarCategorias.setText("Modificar");
						btnModificarCategorias.setBounds(166, 142, 103, 31);
						btnModificarCategorias.setActionCommand("Modificar");
					}
				}
				{
					scpCategorias = new JScrollPane();
					pnlCategorias.add(scpCategorias);
					scpCategorias.setBounds(62, 259, 437, 140);
					{
						TableModel tblCategoriasModel = 
							new DefaultTableModel(
									new String[][] { { "", "" }, { "", "" },{ "", "" }, { "", "" },{ "", "" }, { "", "" },{ "", "" }, { "", "" },{ "", "" }, { "", "" },{ "", "" }, { "", "" },{ "", "" }, { "", "" },{ "", "" }, { "", "" },{ "", "" }, { "", "" },{ "", "" }, { "", "" },{ "", "" }, { "", "" },{ "", "" }, { "", "" },{ "", "" }, { "", "" },{ "", "" }, { "", "" } },
									new String[] { "Codigo", "Descripcion" });
						tblCategorias = new JTable();
						scpCategorias.setViewportView(tblCategorias);
						tblCategorias.setModel(tblCategoriasModel);
					}
				}
			}
			
			pack();
			this.setSize(575, 465);
		} catch (Exception e) {
		    //add your error handling code here
			e.printStackTrace();
		}
	}
    public void addlistener(ActionListener actionlistener){
    	btnModificarCategorias.addActionListener(actionlistener);
    	btnOkCategorias.addActionListener(actionlistener);
    	btnCancelarCategorias.addActionListener(actionlistener);
    	btnBuscar.addActionListener(actionlistener);
    }
    
    
	
    public JTextField getTxtCodigo() {
		return txtCodigo;
	}

	public JTextField getTxtDescripcion() {
		return txtDescripcion;
	}

	public void setTxtDescripcion(JTextField txtDescripcion) {
		this.txtDescripcion = txtDescripcion;
	}

	public JTable gettblCategorias(){
    	
    	return tblCategorias;
    }
	
	public void bloquearNuevo(){
		
		pnlDatosCategorias.setEnabled(false);
		}
	
	public void habilitarNuevo(){
		
		pnlDatosCategorias.setEnabled(true);
		}
	
	public void limpiarCancelar(){
		pnlDatosCategorias.setEnabled(true);
		txtCodigo.setText("");
		txtDescripcion.setText("");
		}
	
	public void bloquearCodigo(){
		
		txtCodigo.setEnabled(false);
		}
	
	public void mostrarMensaje(String mensaje) {
		JOptionPane.showMessageDialog(this, mensaje);
	}
	
}
